# ruby exercise - intermediate
# mario hsieh


def attack(num)
	# set monsters health
	monster1 = {:health => 500}
	monster2 = {:health => 500}

	for i in 1..num
		attack = rand(0..100)
		puts "monster1 attacks monster2 with #{attack} damage"
		monster2[:health] -= attack
		puts "monster2's health is now #{monster2[:health]}/500"
		attack = rand(0..100)
		puts "monster2 attacks monster1 with #{attack} damage"	
		monster1[:health] -= attack
		puts "monster1's health is now #{monster1[:health]}/500"
	end		
	
	puts "monster1 wins!" if monster1[:health] > monster2[:health]
	puts "monster2 wins!" if monster1[:health] < monster2[:health]
	puts "tie game!" if monster1[:health] == monster2[:health]

end

puts attack(5)














